﻿using System;
using System.Web.Mvc;

namespace BoneSystem.Extensions.TabControll
{
    public class TabPageControl : Component
    {
        public new TabPageSettings Settings { get; set; }

        public TabPageControl()
        {
            Settings = new TabPageSettings();
        }
        public TabPageControl(Component component)
        {
            Component = component;
        }
        public Component Component { get; set; }
        public override MvcHtmlString GetHtmlString()
        {
            return new MvcHtmlString(GetTag().ToString(TagRenderMode.Normal));
        }

        internal override AngularTag GetTag()
        {
            if (string.IsNullOrEmpty(Settings.Name))
            {
                throw new Exception("Propriedade Name não informada.");
            }
            var tabPageDiv = new AngularTag("div");
            tabPageDiv.Attributes["class"] = "tab-pane fade in active";
            tabPageDiv.Attributes["id"]= Settings.Name + "Tab";

            tabPageDiv.InnerHtml = Component.GetHtmlString().ToHtmlString();
            return tabPageDiv;
        }
    }
}
